﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SchoolProject2012.Functions;
using SchoolProject2012.Areas.Eleve.Models;

namespace SchoolProject2012.Areas.Eleve.Controllers
{
    [Authorize]
    public class HomeController : Controller
    {
        private EleveSchoolProjectBddEntities db = new EleveSchoolProjectBddEntities();
        //
        // GET: /Eleve/Home/

        [Authorize(Roles = "Admin, Eleve, Delegue, BDE")]
        public ActionResult Index(string langue)
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Field.getLanguage(langue));
            ViewBag.langue = langue;
            try
            {
                return View();
            }
            catch
            {
                return View("Error");
            }
        }

        // Affichage des infos de l'utilisateur
        public PartialViewResult Users(string langue)
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Field.getLanguage(langue));
            string login = Session["login"].ToString();
            ELEVE e = db.ELEVE.Single(x => x.LOGINPERS == login);
            return PartialView(e);
        }

    }
}
